import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from "redux"
import { Switch,Route,NavLink,Redirect } from 'react-router-dom'
import "./index.css"
import Home from "../Home/Home"
import Cate from "../Cate/Cate"
import Shop from "../Shop/Shop"
import Mine from "../Mine/Mine"
import {actions} from "../../store/modules/index.js"
 class Index extends Component {
    render() {
        let {reqCartadd}=this.props
        return (
            <div>
                <Switch>
                    <Route path="/index/home" reqCartadd={reqCartadd} component={Home}></Route>
                    <Route path="/index/cate" component={Cate}></Route>
                    <Route path="/index/shop" component={Shop}></Route>
                    <Route path="/index/mine" component={Mine}></Route>
                    <Redirect to="/index/home"></Redirect>
                </Switch>

                <footer className="index-navs">
                    <NavLink to="/index/home" activeStyle={{ color: 'orange' }}>首页</NavLink>
                    <NavLink to="/index/cate" activeStyle={{ color: 'orange' }}>分类</NavLink>
                    <NavLink to="/index/shop" activeStyle={{ color: 'orange' }}>购物车</NavLink>
                    <NavLink to="/index/mine" activeStyle={{ color: 'orange' }}>我的</NavLink>
                </footer>
            </div>
        )
    }
}
const mapStateToProps = (state) => ({
   
})

const mapDispatchToProps = dispatch => ({
    index: bindActionCreators(actions, dispatch)
})

export default connect(mapStateToProps, mapDispatchToProps)(Index)